import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PatientInfoVO, PatientInfoForm, PatientInfoQuery } from '@/api/basicPublic/patientInfo/types';

/**
 * 查询患者基本信息列表
 * @param query
 * @returns {*}
 */

// 导出一个函数，用于获取患者信息列表
export const listPatientInfo = (query?: PatientInfoQuery): AxiosPromise<PatientInfoVO[]> => {
  // 发送一个get请求，获取患者信息列表
  return request({
    url: '/basicPublic/patientInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询患者基本信息详细
 * @param id
 */
export const getPatientInfo = (id: string | number): AxiosPromise<PatientInfoVO> => {
  return request({
    url: '/basicPublic/patientInfo/' + id,
    method: 'get'
  });
};

export const getBasicInfo = (id: string | number)=> {
  return request({
    url: '/basicPublic/basicInfo/' + id,
    method: 'get'
  });
};

export const getHealthCheckUps = (id: string | number)=> {
  return request({
    url: '/basicPublic/healthCheckUps/getHistoryList/' + id,
    method: 'get'
  });
};

export const getHypertensionFollowup = (id: string | number)=> {
  return request({
    url: '/basicPublic/hypertensionFollowup/getHistoryList/' + id,
    method: 'get'
  });
};

export const getDiabetesFollowup = (id: string | number)=> {
  return request({
    url: '/basicPublic/diabetesFollowup/getHistoryList/' + id,
    method: 'get'
  });
};

export const getTcmConstitutionIdentification = (id: string | number)=> {
  return request({
    url: '/basicPublic/tcmConstitutionIdentification/getHistoryList/' + id,
    method: 'get'
  });
};

/**
 * 新增患者基本信息
 * @param data
 */
export const addPatientInfo = (data: PatientInfoForm) => {
  return request({
    url: '/basicPublic/patientInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改患者基本信息
 * @param data
 */
export const updatePatientInfo = (data: PatientInfoForm) => {
  return request({
    url: '/basicPublic/patientInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除患者基本信息
 * @param id
 */
export const delPatientInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/basicPublic/patientInfo/' + id,
    method: 'delete'
  });
};

/**
 * 查询用户列表作为医生字典
 */
export const getDoctorDict = () => {
  return request({
    url: '/basicPublic/patientInfo/listDoctor',
    method: 'get'
  });
};
